import request from '@/utils/request'

// 查询学生所在学习小组列表
export function listStuGroup(query) {
  return request({
    url: '/exam/group/selectExamGroupListByUserId',
    method: 'get',
    params: query
  })
}

/**
 * 查询学习小组的学习资料列表-学生端
 * @param {*} groupId 
 * @param {*} query 
 * @returns 
 */
export function listStuGroupMaterial(groupId, query) {
  return request({
    url: '/exam/learnMeterial/selectMaterialsByUserId/' + groupId,
    method: 'get',
    params: query
  })
}

// 查询学习小组的考试科目列表-学生端
export function listStuGroupSubject(groupId, query) {
  return request({
    url: '/exam/subject/selectExamSubjectListByUserId/' + groupId,
    method: 'get',
    params: query
  })
}

/**
 * 查询学习小组的考试科目列表-教师端
 * @param {*} groupId 
 * @param {*} query 
 * @returns 
 */
export function getExamineDetail(groupId, query) {
  return request({
    url: '/exam/examine/getExamineDetail/' + groupId,
    method: 'get',
    params: query
  })
}

/**
 * 查询学习小组的学习情况-教师端
 * @param {*} groupId 
 * @param {*} query 
 * @returns 
 */
export function getLearnDetail(groupId, query) {
  return request({
    url: '/exam/examine/getLearnDetail/' + groupId,
    method: 'get',
    params: query
  })
}

/**
 * 统计学习次数 (已删除)
 * @param {*} type 
 * @returns 
 */
export function viewStats(data) {
  return request({
    url: '/exam/learnMeterial/learn/timeStats',
    method: 'post',
    data: data
  })
}

/**
 * 开始考试
 * @param {*} type 
 * @param {*} data 
 * @returns 
 */
export function startExam(data) {
  return request({
    url: '/exam/examine/start',
    method: 'post',
    data: data
  })
}

/**
 * 查询考试基础信息
 */
export function getExamineBaseInfo(examineId) {
  return request({
    url: '/exam/examine/find/' + examineId,
    method: 'get'
  })
}

/**
 * 获取考试题目列表
 * 包括考试题目、选项、学生提交的答案
 * @param {*} examineId 
 * @returns 
 */
export function getExamineQuestions(examineId) {
  return request({
    url: '/exam/examine/findQuestions/' + examineId,
    method: 'get'
  })
}

/**
 * 获取学生考试详情
 * @param {*} examineId 
 * @returns 
 */
export function findExamineAnswer(examineId) {
  return request({
    url: '/exam/examine/findExamineAnswer/' + examineId,
    method: 'get'
  })
}

/**
 * 实时保存答案
 * @param {*} data 
 * @returns 
 */
export function updateAnswer(data) {
  return request({
    url: '/exam/examine/updateAnswer',
    method: 'post',
    data: data
  })
}

/**
 * 交卷
 * @param {*} data 
 * @returns 
 */
export function completeExam(data) {
  return request({
    url: '/exam/examine/complete',
    method: 'post',
    data: data
  })
}

/**
 * 删除学习记录
 * @param {*} data 
 * @returns 
 */
export function delLearn(statsId) {
  return request({
    url: '/exam/examine/delLearn/' + statsId,
    method: 'delete'
  })
}

/**
 * 提交阅卷结果
 * @param {*} examineId 
 * @returns 
 */
export function judgeExamine(examineId, data) {
  return request({
    url: '/exam/examine/judge/' + examineId,
    method: 'post',
    data: data
  })
}

/**
 * 删除考试记录
 * @param {*} examineId 
 * @returns 
 */
export function delExamine(examineId) {
  return request({
    url: '/exam/examine/delExamine/' + examineId,
    method: 'delete'
  })
}